﻿Imports System.Data.OleDb

Public Class FilmReview
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

    End Sub

    Protected Sub btn_rate_Click(sender As Object, e As EventArgs) Handles btn_rate.Click
        Dim conn As OleDbConnection = New OleDbConnection(ConfigurationManager.ConnectionStrings("godzillaFilms").ConnectionString)
        conn.Open()
        Dim rmsql = "DELETE FROM filmRatings WHERE Rater=@f1 AND FilmID=@f2"
        Dim rmcmd As New OleDbCommand(rmsql, conn)
        rmcmd.Parameters.AddWithValue("@f1", User.Identity.Name)
        rmcmd.Parameters.AddWithValue("@f2", Request.Params("ID"))
        rmcmd.ExecuteNonQuery()
        Dim sql = "INSERT INTO filmRatings (Rating, FilmID, Rater) VALUES (@f1, @f2, @f3)"
        Dim cmd As OleDbCommand = New OleDbCommand(sql, conn)
        cmd.Parameters.AddWithValue("@f1", Rating2.CurrentRating)
        cmd.Parameters.AddWithValue("@f2", Request.Params("ID"))
        cmd.Parameters.AddWithValue("@f3", User.Identity.Name)
        cmd.ExecuteNonQuery()
        conn.Close()
        Response.Redirect("filmDetail.aspx?ID=" & Request.Params("ID"))
    End Sub
End Class